package com.cy.pj.common.util;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * @DATE: 2021/3/12 14:43
 * @Author: LuckyH
 */
public class ServletUtil {
    // 请求对象
    public static HttpServletRequest getRequest(){
        return getServletRequestAttributes().getRequest();
    }

    // 通过RequestContextHolder 类型获取请求属性
    public static ServletRequestAttributes getServletRequestAttributes(){
        return (ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
    }
}
